﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;

namespace Model.EntityModel.Auth
{
    /// <summary>
    /// 部门主表（支持层级结构）
    ///</summary>
    [SugarTable("DEPT_MASTER")]
    public class Dept
    {
        /// <summary>
        /// 部门ID (全局唯一GUID)
        ///</summary>
        [SugarColumn(ColumnName = "ID", IsPrimaryKey = true, Length = 36)]
        public string Id { get; set; } = Guid.NewGuid().ToString();

        /// <summary>
        /// 部门名称 
        ///</summary>
        [SugarColumn(ColumnName = "NAME")]
        public string Name { get; set; }

        /// <summary>
        /// 父部门ID (顶级部门为空)
        ///</summary>
        [SugarColumn(ColumnName = "PARENT_ID", Length = 36, IsNullable = true)]
        public string ParentId { get; set; }  // 新增层级支持

        /// <summary>

        /// <summary>
        /// 子部门列表（非数据库字段）
        ///</summary>
        [SugarColumn(IsIgnore = true)]
        public List<Dept> Children { get; set; } = new List<Dept>();

        [SugarColumn(ColumnName = "CREATED_BY")]
        public string CreatedBy { get; set; }

        [SugarColumn(ColumnName = "CREATED_AT")]
        public DateTime? CreatedAt { get; set; } = DateTime.Now;
    }
}
